package com.tianji.remark.controller;


import com.tianji.remark.domain.dto.LikeRecordFormDTO;
import com.tianji.remark.service.ILikedRecordService;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.context.annotation.Lazy;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Set;

/**
 * <p>
 * 点赞记录表 前端控制器
 * </p>
 *
 * @author xzh
 * @since 2024-03-16
 */
@RestController
@RequestMapping("/likes")
@AllArgsConstructor(onConstructor_={@Lazy} )
public class LikedRecordController {

    private final ILikedRecordService likedRecordService;

    /**
     * 增加或取消点赞
     * @param likeRecordFormDTO
     */
    @PostMapping
    @ApiOperation(value = "增加或取消点赞")
    public void addLikeRecord(@RequestBody LikeRecordFormDTO likeRecordFormDTO){
        likedRecordService.addLikeRecord(likeRecordFormDTO);
    }

    /**
     * 查询用户是否对某个业务点赞
     * @param bizIds
     * @return
     */
    @GetMapping("/list")
    @ApiOperation(value = "查询用户是否对某个业务点赞")
    public Set<Long> isBizLiked(@RequestParam("bizIds") List<Long> bizIds){
        return likedRecordService.isBizLiked(bizIds);
    }



}
